import {
  API_BASE, WS_BASE
} from '@/config'

export const Urls = {
  server: API_BASE,
  wsServer: WS_BASE,

  req: {
    sessionCode: "/travel/api/session/code",
    isUserLogin: "/travel/api/session/isUserLogin",
    isSubscribe: "/travel/api/user/subscribe",
    isAdmin: "/travel/api/user/admin",
    avatarUpload: "/travel/api/upload/avatar",
    saveUser: "/travel/api/user/save",
    saveMobile: "/travel/api/user/savemobile",
    saveAvatar: "/travel/api/user/saveavatar",
    
    featureOptions: "/travel/api/options/features",
    budgeOptions: "/travel/api/options/budges",
    catOptions: "/travel/api/options/cat",
    hotelOptions: "/travel/api/options/hotels",
    foodOptions: "/travel/api/options/foods",
    customOptions: "/travel/api/options/custom",
    
    hotPlans: "/travel/api/plan/hot",
    searchPlans: "/travel/api/plan/search",
    agreePlan: "/travel/api/plan/agree",
    collectPlan: "/travel/api/plan/collect",
    scorePlan: "/travel/api/plan/score",
    planBase: "/travel/api/plan/base",
    planDay: "/travel/api/plan/day",
    planSummary: "/travel/api/plan/summary",
    planMarkers: "/travel/api/plan/markers",
    promotionPlan: "/travel/api/plan/promotion",

    planningAsk: "/travel/api/planning/ask",
    planningReq: "/travel/api/planning/req",
    planningOriReq: "/travel/api/planning/originreq",
    planningProcess: "/travel/api/planning/process",
    planningPlan: "/travel/api/planning/plan",
    adoptedPlan: "/travel/api/planning/adopted",
    cancelPlan: "/travel/api/planning/cancel",
    
    sightGet: "/travel/api/plan/sight/",
    hotelGet: "/travel/api/plan/hotel/",
    resGet: "/travel/api/plan/res/",
    sightImages: "/travel/api/plan/images/sight",
    hotelImages: "/travel/api/plan/images/hotel",
    resImages: "/travel/api/plan/images/res",

    hotelSearch: "/travel/api/place/hotels",
    addrHot: "/travel/api/place/hot",
    addrProv: "/travel/api/place/prov",
    addrGroup: "/travel/api/place/group",
    addrSearch: "/travel/api/place/search",
    
    
    myStat: "/travel/api/my/stat",
    myPlans: "/travel/api/my/plans",
    myCollects: "/travel/api/my/collects",

  },

  getApi: function(key) {
    let api = this.req[key] || '';
    return api;
  },
  getReq: function(key) {
    let sub = this.req[key];
    if (!sub) {
      return this.server;
    }
    return this.server + sub;
  }

}

function install(app) {
  app.config.globalProperties.$urls = Urls
}

export default {
  install
}
